---
description: "Reference for Nitric's Dart library - Store a new secret value"
---

# Dart - secret.put()

<Note>
  This is reference documentation for the Nitric Dart SDK. To learn about
  Secrets in Nitric start with the [Secrets docs](/secrets).
</Note>

Store a new secret value, creating a new [version](./secret-version) to store the value.

```dart
import 'package:nitric_sdk/nitric.dart';

final keyRef = Nitric.secret("apiKey").allow([
  SecretPermission.put,
]);

await keyRef.put("6c3199a3-094e-4797-bfc9-9ee2a7839286");
```

## Parameters

<Properties>
  <Property name="secret" required type="String">
    The new secret value to store in the secrets manager.
  </Property>
</Properties>

### Notes

A new secret version is always created when calling `put()`, the versions will automatically be provided a unique id. This behavior is dependent on the underlying secrets manager.

## Examples

### Store a new secret value

```dart
import 'package:nitric_sdk/nitric.dart';

final keyRef = Nitric.secret("apiKey").allow([
  SecretPermission.put,
]);

await keyRef.put("6c3199a3-094e-4797-bfc9-9ee2a7839286");
```

### Get the id of a new secret version

Calling `put()` returns a promise to a reference to the new secret version. Storing the ID of the new version can be useful if you need to retrieve that specific value again in future using [version.access()](./secret-version-access)

```dart
import 'package:nitric_sdk/nitric.dart';

final keyRef = Nitric.secret("apiKey").allow([
  SecretPermission.put,
]);

final newApiKeyVersionRef = await keyRef.put(
  "6c3199a3-094e-4797-bfc9-9ee2a7839286"
);

final versionId = newApiKeyVersionRef.version;
```
